package maps

import (
	"gitee.com/injoyai/goutil/conv"
)

var (
	//map合集,不开放,防止数据类型强转错误
	defaultMaps *Safe
)

// Take 名字待定
func Take(keys ...string) *Safe {
	key := conv.GetDefaultString("_default", keys...)
	if defaultMaps == nil {
		defaultMaps = NewSafe()
	}
	val := defaultMaps.GetVar(key)
	if !val.IsNil() {
		value, ok := val.Val().(*Safe)
		if ok {
			return value
		}
	}
	newMap := NewSafe()
	defaultMaps.Set(key, newMap)
	return newMap
}

//func Has(key interface{}) bool {
//	return Take().Has(key)
//}
//
//func Get(key interface{}) (interface{}, bool) {
//	return Take().Get(key)
//}

//func GetVar(key interface{}) *conv.Var {
//	return Take().GetVar(key)
//}

//func Set(key, val interface{}) {
//	Take().Set(key, val)
//}

//func Del(key interface{}) {
//	Take().Del(key)
//}
//
//func GetAndDel(key interface{}) *conv.Var {
//	return Take().GetAndDel(key)
//}
//
//func GetAndSet(key, value interface{}, expiration ...time.Duration) *conv.Var {
//	return Take().GetAndSet(key, value, expiration...)
//}
//
//func GetOrSet(key, value interface{}, expiration ...time.Duration) *conv.Var {
//	return Take().GetOrSet(key, value, expiration...)
//}
//
//func GetOrSetByHandler(key interface{}, handler func() (interface{}, error), expiration ...time.Duration) (*conv.Var, error) {
//	return Take().GetOrSetByHandler(key, handler, expiration...)
//}
//
//func Map() map[interface{}]interface{} {
//	return Take().Map()
//}
//
//func GMap() map[string]interface{} {
//	return Take().GMap()
//}
//
//func Clone() *Safe {
//	return Take().Clone()
//}
